﻿using FE.Applicaiton.Request;
using FE.Application;
using System.Web.Mvc;

namespace FE.PDFConvert.Tools.Controllers
{
    public class HomeController : Controller
    {
        private static readonly NLog.Logger Logger = NLog.LogManager.GetCurrentClassLogger();

        public ActionResult Index()
        {
            return View();
        }

        public ActionResult About()
        {
            ViewBag.Message = "Your application description page.";

            return View();
        }

        public ActionResult Contact()
        {
            ViewBag.Message = "Your contact page.";

            return View();
        }

        public string Convert()
        {
            PDFService.Convert();

            return "ok";
        }

        public string Log()
        {
            Logger.Info("Hello world");
            Logger.Error("err msg");

            return "log";
        }

        public string Http()
        {
            var res = HttpHelper.HandleWebRequest(@"http://127.0.0.1:8080/backgroupport",
                 @"{""op"":""PdfList"",""params"":{},""version"":""V3.12.42.150 Beta6.06 Build 2020.01.03.14.48""}");

            return res ? "ok" : "failed!";
        }

        public string Down()
        {
            var res = HttpHelper.HandleWebRequest(@"http://127.0.0.1:8080/backgroupport",
                @"{""op"":""PdfList"",""params"":{},""version"":""V3.12.42.150 Beta6.06 Build 2020.01.03.14.48""}");

            return res ? "ok" : "failed!";
        }
    }
}